<!DOCTYPE html>
<html lang="zh">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
    <title>computed和methods的区别</title>
</head>

<body>
    <div id="app">
        <p>Computed Full Name:{{ fullName }}</p>
        <p>Method Full Name:{{getFullName()}}</p>
    </div>
    <script>
        const App = {
            data() {
                return {
                    firstName: 'John',
                    lastName: 'Doe'
                };
            },
            computed: {
                fullName() {
                    console.log('Computed fullName called');
                    return `${this.firstName} ${this.lastName}`;
                }
            },
            methods: {
                getFullName() {
                    console.log('Method getFullName called');
                    return `${this.firstName} ${this.lastName}`;
                }
            }
        };
        Vue.createApp(App).mount('#app');
    </script>
</body>

</html>